﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Db;
using System.Data;
using Framework.Kit;

namespace BLL.Service
{
    /// <summary>
    /// 拍卖会服务
    /// </summary>
    public class auctionService : DbBase
    {

        // 根据拍卖会编号获取拍卖会信息
        public Model.auctionModel getAuction(string auction_no)
        {
            try
            {
                Model.auctionModel auction = new Model.auctionModel();

                StringBuilder sql = new StringBuilder();
                sql.Append("SELECT * FROM  AUCTION WHERE  AUCTION_NO = '");
                sql.Append(auction_no).Append("'");
                DataTable dt = this.queryDtSQL(sql.ToString());
                if (dt.Rows.Count == 1)
                {
                    auction.Auction_ADD = dt.Rows[0]["AUCTION_ADD"].ToString();
                    auction.Auction_DATE = Convert.ToDateTime(dt.Rows[0]["AUCTION_DATE"]);
                    auction.Auction_NAME = dt.Rows[0]["AUCTION_NAME"].ToString();
                    auction.Auction_NO=dt.Rows[0]["AUCTION_NO"].ToString();
                    return auction;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                other.WriteErrLog("获取当前需要拍卖会信息", ex);
                return null;
            }
        }

        // 获取当前日期的拍卖会
        public DataTable getAuctionLst(String auctionDate,String auctionStatus) 
        {
            try
            {               
                StringBuilder sql = new StringBuilder();
                sql.Append("SELECT * FROM AUCTION WHERE  AUCTION_DATE = TO_DATE('");
                sql.Append(auctionDate).Append("', 'YYYY-MM-DD') AND DEL_FLG='0' AND AUCTION_STATUS='").Append(auctionStatus).Append("'");
                return  this.queryDtSQL(sql.ToString());
            }
            catch (Exception ex)
            {
                other.WriteErrLog("获取当前日期的拍卖会列表", ex);
                return null;
            }
        }
    }
}
